<?php
// View for registered.users.admins
require_once WACT_ROOT.'controller/controller.inc.php';
require_once WACT_ROOT .'controller/form.inc.php';
require_once WACT_ROOT.'view/view.inc.php';
require_once WACT_ROOT .'view/formview.inc.php';

require_once APP_ROOT . 'view/common/layout.formview.php';

require_once 'model/common/user.php';
require_once 'model/common/state.php';

class RegisteredUsersListView extends LayoutFormView {

    function RegisteredUsersListView($TemplateFile) {
        parent :: LayoutFormView($TemplateFile);
    }

    //function supressFormErrors() {
         //$dataset = array (array ());
         //$empty_set =& new ArrayDataSet($list_updated);

    	//$this->Template->setChildDataSource('Summary', $empty_set);
    //}

    function prepare(&$controller, &$request, &$responseModel) {
    	parent::prepare($controller, $request, $responseModel);
        
		$this->Template->set('SITE_CSS',Site::getSiteTemplateCSS());
		$this->Template->set('SITE_BASE',Site::getSiteTemplateBase());
		$this->Template->set('SITE_TITLE',Site::getTitle());
 

    	// populate list
        $pager =& $this->Template->getChild('pagenav');
        $list =& User::getRegisteredUsersList($pager);

        $list_updated=array();

        //$list->export();
        //$data =& $list->exportDataSetAsArray();
        $list->reset();
        while ($list->next()) {
        	// adjust active property
        	$dataspace =& $list->export();

            if ($list->hasProperty('active')) {
        		$active = $list->get('active');
        		//print 'active='.$active;
        		//if (!$active) $list->remove('active');
        		if ($active>0) {
        			//$list->set('active_show',1);
        			//print 'active_show='."1";
        			//$dataspace->merge(array('active_show'=>1));

        			$dataspace = array_merge($dataspace,array('active_show'=>1));
        			//print_r($dataspace); print "\n";
        		}
        	}
            $list_updated = array_merge($list_updated,array($dataspace));
        }
        //print_r($data);
        $list_source_updated =& new ArrayDataSet($list_updated);

        $this->Template->setChildDataSource('List', $list_source_updated);

        $active = $responseModel->get('active');
        if ($active>0) $responseModel->set('active_show',1);

        // populate states
        $state = $responseModel->get('state');
        $states =& $this->Template->getChild('state');
        //$states_list = array('(ALL)'=>'(ALL)','AL'=>'AL','MS'=>'MS','MS'=>'WS');
        $states_list =& State::getStates();
        $states->setChoices($states_list);
        $states->setSelection($state);
    }

}



?>